package dbms.check;

import dbms.Debug;
import dbms.absyn.*;
import dbms.server.DbmsServer;

public class CheckType {
	
	String attr;
	String table;
	Value value;

	public CheckType(String a, String t, Value v) {
		attr = a;
		table = t;
		value = v;
	}
	
	public boolean IsTypeCorrect() {
		int type = DbmsServer.masterPage.tableMap.get(table).table.getTableSchema().getInfo().get(attr).getType();
		if (type == value.type) return true;
		return false;
	}

	public void check() {
		if (!IsTypeCorrect()) Debug.Error("The type of Value:" + value + "is not matched!");
	}

}
